package com.working.libbase.base

import android.graphics.drawable.ColorDrawable
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.annotation.LayoutRes
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.DialogFragment
import com.working.libcommon.exts.cast
import com.working.libcommon.exts.statusBarColor

abstract class BaseDialogFragment : DialogFragment() {
    protected inline fun <reified T : ViewDataBinding> binding(
        inflater: LayoutInflater,
        @LayoutRes resId: Int,
        container: ViewGroup?
    ): T = DataBindingUtil.inflate(inflater, resId, container, false)

    fun immerseColor(colorInt: Int) {
        activity?.cast<AppCompatActivity>()?.supportActionBar?.setBackgroundDrawable(
            ColorDrawable(
                colorInt
            )
        )
        activity?.statusBarColor(colorInt)
    }

}